import { getToken } from "@/utils/cache/cookies"
import { request } from "@/utils/service"
import axios from "axios"
const baseURL = import.meta.env.VITE_BASE_API
// 增加纠纷订单
export function AddComplaintApi(data: any) {
  return request({
    url: "/complaint/add",
    method: "post",
    data
  })
}
// 查找纠纷订单
export function getComplaintApi(params: any) {
  return request({
    url: "/complaint/query",
    method: "get",
    params
  })
}
// 修改订单状态
export function updateComplaintApi(data: any) {
  return request({
    url: "/complaint/update",
    method: "put",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    data
  })
}
// 图片上传
export function ComplaintUpload(data: any) {
  return request({
    url: "/complaint/upload",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    data
  })
}
// 提交进度
export function addMessageApi(data: any) {
  return request({
    url: "/complaint/addMessage",
    method: "post",
    data
  })
}
// 查看进度
export function queryMessageApi(params: any) {
  return request({
    url: "/complaint/queryMessage",
    method: "get",
    params
  })
}
// 以首回按钮状态修改
export function SHbuttonApi(params: any) {
  return request({
    url: "/complaint/update",
    method: "put",
    params
  })
}

// 生成工单 complaintTickets/add
export function workOrderApi(data: any) {
  return request({
    url: "/complaintTickets/add",
    method: "post",
    data
  })
}
// 工单修改状态
export function workOrderUpdateApi(data: any) {
  return request({
    url: "/complaintTickets/update",
    method: "post",
    data
  })
}
// 查看工单
export function workOrderQueryApi(params: any) {
  return request({
    url: "/complaintTickets/query",
    method: "get",
    params
  })
}
// 下载投诉已完结 rechargeRecord
export function rechargeRecord(data: any) {
  return axios({
    url: `${baseURL}/complaint/downComplaint`,
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    responseType: "blob",
    data
  })
}
//  删除工单
export function deleteComplaintApi(id: any) {
  return request({
    url: "/complaint/del",
    method: "delete",
    params: {
      id
    }
  })
}
// 下载工单免责和不免责
export function downLoadOrderTable(data: any) {
  return axios({
    url: `${baseURL}/complaintTickets/downOrder`,
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    responseType: "blob",
    data
  })
}
// 工单日志
export function getWorkRZ(params: any) {
  return request({
    url: "/complaint/queryLog",
    method: "get",
    params
  })
}
